<?php
/*
	[UCenter Home] (C) 2007-2008 Comsenz Inc.
	$Id: profile.php 2009-11-3 $ 
*/

if(!defined('IN_UCHOME')) {
	exit('Access Denied');
}

include_once(S_ROOT.'./source/function_cp.php');
include_once(S_ROOT.'./site/libs/func_util.php');
include_once(S_ROOT.'./site/libs/func_model.php');

$li_name = 'hot';
$nav_name = '正流行';

$page = empty($_GET['page'])?1:intval($_GET['page']);
if($page<1) $page=1;

$theurl = "site.php?ac=hot";

$perpage = 16;
$start = ($page-1)*$perpage;
//检查开始数
ckstart($start, $perpage);

$count = $_SGLOBAL['db']->result($_SGLOBAL['db']->query("SELECT COUNT(*) FROM ".tname('spot')),0);

$sql = "SELECT DISTINCT p1.tagname AS p1title, p1.pic AS p1pic, sp.*, p2.tagname AS p2title, p2.pic AS p2pic, pic.* AS spotpic FROM ".tname('spot')." sp LEFT JOIN ".tname('mtag')." p1 ON p1.tagid=sp.tag1 LEFT JOIN ".tname('mtag')." p2 ON p2.tagid=sp.tag2, ".tname('pic')." AS pic WHERE sp.last_picid=pic.picid ORDER BY sp.pic_cnt DESC LIMIT $start,$perpage";
		
 $query = $_SGLOBAL['db']->query($sql);
 while ($value = $_SGLOBAL['db']->fetch_array($query)) {
		$value['spot_pic'] = $value['last_picid'] != '0'  ? mkpicurl($value, 0) : "image/nologo.jpg";
        $value['p1pic'] = $value['p1pic']?$value['p1pic']:"image/nologo.jpg";
        $value['p2pic'] = $value['p2pic']?$value['p2pic']:"image/nologo.jpg";
		$spotlist[] = $value;
 }
 
//print_r($spotlist);
//分页
$multi = multi($count, $perpage, $page, $theurl);

include template('site/tpl/hotspot');
exit;
?>
